#!/bin/bash

# Flutter环境启动脚本

echo "🚀 Flutter多环境启动脚本"
echo ""

# 检查参数
if [ $# -eq 0 ]; then
    echo "用法: ./run_env.sh [环境名] [可选的flutter run参数]"
    echo ""
    echo "可用环境:"
    echo "  dev   - 开发环境"
    echo "  test  - 测试环境"
    echo "  prod  - 生产环境"
    echo ""
    echo "示例:"
    echo "  ./run_env.sh dev"
    echo "  ./run_env.sh test --release"
    echo "  ./run_env.sh prod --release --target-platform android-arm64"
    exit 1
fi

ENV=$1
shift  # 移除第一个参数，剩下的作为flutter run的参数

case $ENV in
    "dev")
        echo "🔧 启动开发环境..."
        flutter run --dart-define=ENV=dev "$@"
        ;;
    "test")
        echo "🧪 启动测试环境..."
        flutter run --dart-define=ENV=test "$@"
        ;;
    "prod")
        echo "🌟 启动生产环境..."
        flutter run --dart-define=ENV=prod "$@"
        ;;
    *)
        echo "❌ 未知环境: $ENV"
        echo "可用环境: dev, test, prod"
        exit 1
        ;;
esac
